var e = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../@babel/runtime/regenerator")), t = require("../../../../@babel/runtime/helpers/asyncToGenerator");

Component({
    properties: {
        resultData: {
            type: Object,
            value: {}
        }
    },
    data: {
        query: null,
        mouseText: "",
        bmiText: {
            text: "根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥",
            tempText: "根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减",
            mouseText: "",
            optFlag: !1,
            curOpt: "close"
        },
        whiText: {
            text: "根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥",
            tempText: "根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减肥。根据WS/T 428-2013成人体重判定，您已经非常苗条了。前往不要盲目节食减",
            mouseText: "",
            optFlag: !1,
            curOpt: "close"
        }
    },
    methods: {
        gotoDetail: function(e) {
            var t = e.currentTarget.dataset.item;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + t.goods_id
            });
        },
        getViewRect: function(e) {
            var t = this.data.query;
            return new Promise(function(a, r) {
                t.select(e).boundingClientRect(function(e) {
                    a(e);
                }).exec();
            });
        },
        setBmiTextStatus: function() {
            var e = this.data.bmiText.curOpt;
            "close" == e ? this.setData({
                "bmiText.tempText": this.data.bmiText.text,
                "bmiText.curOpt": "open"
            }) : "open" == e && this.setData({
                "bmiText.tempText": this.data.bmiText.mouseText,
                "bmiText.curOpt": "close"
            });
        },
        setWhiTextStatus: function() {
            var e = this.data.whiText.curOpt;
            "close" == e ? this.setData({
                "whiText.tempText": this.data.whiText.text,
                "whiText.curOpt": "open"
            }) : "open" == e && this.setData({
                "whiText.tempText": this.data.whiText.mouseText,
                "whiText.curOpt": "close"
            });
        },
        setBmiText: function() {
            var a = this;
            return t(e.default.mark(function t() {
                var r, i, n, s, u, x, c;
                return e.default.wrap(function(e) {
                    for (;;) switch (e.prev = e.next) {
                      case 0:
                        return e.next = 2, a.getViewRect(".bmiText .text");

                      case 2:
                        return r = e.sent, e.next = 5, a.getViewRect(".bmiText .text .content");

                      case 5:
                        if (i = e.sent, !(r.height >= i.height)) {
                            e.next = 8;
                            break;
                        }
                        return e.abrupt("return");

                      case 8:
                        n = a.data.bmiText.text.split(""), s = "", u = n.length, x = 2 * r.width - r.width / 2, 
                        a.setData({
                            mouseText: ""
                        }), c = 0;

                      case 14:
                        if (!(c < u)) {
                            e.next = 27;
                            break;
                        }
                        return e.next = 17, a.getViewRect(".mouseText");

                      case 17:
                        if (!(e.sent.width < x)) {
                            e.next = 23;
                            break;
                        }
                        s += n[c], a.setData({
                            mouseText: s
                        }), e.next = 24;
                        break;

                      case 23:
                        return e.abrupt("break", 27);

                      case 24:
                        c++, e.next = 14;
                        break;

                      case 27:
                        a.setData({
                            "bmiText.mouseText": s + "...",
                            "bmiText.tempText": s + "...",
                            "bmiText.optFlag": !0,
                            "bmiText.curOpt": "close"
                        });

                      case 28:
                      case "end":
                        return e.stop();
                    }
                }, t);
            }))();
        },
        setWhiText: function() {
            var a = this;
            return t(e.default.mark(function t() {
                var r, i, n, s, u, x, c;
                return e.default.wrap(function(e) {
                    for (;;) switch (e.prev = e.next) {
                      case 0:
                        return console.log("执行3"), e.next = 3, a.getViewRect(".whiText .text");

                      case 3:
                        return r = e.sent, e.next = 6, a.getViewRect(".whiText .text .content");

                      case 6:
                        if (i = e.sent, !(r.height >= i.height)) {
                            e.next = 9;
                            break;
                        }
                        return e.abrupt("return");

                      case 9:
                        n = a.data.whiText.text.split(""), s = "", u = n.length, x = 2 * r.width - r.width / 2, 
                        a.setData({
                            mouseText: ""
                        }), c = 0;

                      case 15:
                        if (!(c < u)) {
                            e.next = 28;
                            break;
                        }
                        return e.next = 18, a.getViewRect(".mouseText");

                      case 18:
                        if (!(e.sent.width < x)) {
                            e.next = 24;
                            break;
                        }
                        s += n[c], a.setData({
                            mouseText: s
                        }), e.next = 25;
                        break;

                      case 24:
                        return e.abrupt("break", 28);

                      case 25:
                        c++, e.next = 15;
                        break;

                      case 28:
                        a.setData({
                            "whiText.mouseText": s + "...",
                            "whiText.tempText": s + "...",
                            "whiText.optFlag": !0,
                            "whiText.curOpt": "close"
                        });

                      case 29:
                      case "end":
                        return e.stop();
                    }
                }, t);
            }))();
        }
    },
    ready: function() {
        return t(e.default.mark(function t() {
            return e.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                  case "end":
                    return e.stop();
                }
            }, t);
        }))();
    }
});